package com.yan.thread;

/**
 * @author taoge
 * @Date 2024/8/7 16:36
 * @Description
 */
public class ThreadDemo8 {
    public static void main(String[] args) {
        Thread t1 = new Thread(new MyTask10() , "A");
        MyTask9 t2 = new MyTask9("B");
        t2.setDaemon(true);
        t2.start();
        t1.start();
    }
}
class MyTask9 extends Thread{
    public MyTask9() {
    }

    public MyTask9(String name) {
        super(name);
    }

    @Override
    public void run() {
        for (int i = 0; i < 10000; i++) {
            Thread.yield();
            System.out.println(Thread.currentThread().getName() + "--" +i);
        }
    }
}
class MyTask10 implements Runnable{

    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            System.out.println(Thread.currentThread().getName() +"--" + i);
        }
    }
}